{template 'header'}
<div id="head-bar">
<div class="head-bar">
<div class="head-bar-back">
<a href="{$back_link}" data-direction="reverse"><img src="{DT_MOB}static/img/icon-back.png" width="24" height="24"/><span>返回</span></a>
</div>
<div class="head-bar-title">评论列表</div>
<div class="head-bar-right">
{if $EXT[comment_api]}
<a href="javascript:window.location.reload();"><span>刷新</span></a>
{else}
<a href="javascript:window.scrollTo(0,0);$('#box-btn').slideUp(300);$('#c1').show();$('#c0,#emoji').hide();" id="c0" style="display:none;"><span>取消</span></a>
<a href="javascript:window.scrollTo(0,0);$('#box-btn').slideDown(300);$('#c0').show();$('#c1').hide();" id="c1"><span>发表</span></a>
{/if}
</div>
</div>
<div class="head-bar-fix"></div>
</div>
{if $EXT[comment_api] == 'changyan'}
<div class="main">
	<div id="SOHUCS" sid="{$mid}-{$itemid}"></div>
	<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" 
		src="http://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id={$EXT[comment_api_id]}&conf={$EXT[comment_api_key]}">
	</script>
</div>
{elseif $EXT[comment_api] == 'duoshuo'}
<div class="main" style="padding:0 10px;">
	<div class="ds-thread" data-thread-key="{$mid}-{$itemid}" data-title="{$title}" data-url="{$linkurl}" data-image="{if $thumb}{str_replace('.thumb.'.file_ext($thumb), '', $thumb)}{/if}"></div>
	<script type="text/javascript">
	var duoshuoQuery = {short_name:"{$EXT[comment_api_id]}"};
		(function() {
			var ds = document.createElement('script');
			ds.type = 'text/javascript';ds.async = true;
			ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
			ds.charset = 'UTF-8';
			(document.getElementsByTagName('head')[0] 
			 || document.getElementsByTagName('body')[0]).appendChild(ds);
		})();
	</script>
</div>
{else}
<style type="text/css">
.quote{border:1px solid #DCDCDC;background:#FFFFFF;padding:10px;margin-bottom:10px;}
.quote_title {font-size:12px;color:#007AFF;}
.quote_time {font-size:11px;color:#999999;}
.quote_floor {float:right;font-size:10px;color:#999999;}
.quote_content {clear:both;}
.star_a {display:inline-block;margin:12px 10px 12px 0;padding:2px 8px;height:20px;line-height:20px;background:#FF6600;color:#FFFFFF;font-size:12px;border-radius:6px;}
.star_b {display:inline-block;margin:12px 10px 12px 0;padding:2px 8px;height:20px;line-height:20px;background:#EEEEEE;color:#333333;font-size:12px;border-radius:6px;}
.star_e {display:inline-block;margin:10px 0;padding:2px 8px;height:24px;line-height:24px;width:24px;background:url('{DT_MOB}static/img/chat-emoji.png') no-repeat center center;background-size:24px 24px;float:right;}
.emoji {height:180px;width:100%;background:#FFFFFF;display:none;}
.emoji table {width:100%;}
.emoji td {height:44px;text-align:center;}
.emoji td:hover {background:#F5F5F6;}
</style>
{if $faces}
<div id="emoji" class="emoji bd-b">
<table cellspacing="0" cellpadding="0">
{loop $faces $k $v}
{if $k%10==0}<tr>{/if}
<td onclick="$('#content').val($('#content').val()+':{$v})');"><img src="{DT_STATIC}file/face/{$v}.gif"/></td>
{if $k%10==9}</tr>{/if}
{/loop}
</table>
</div>
{/if}
<div class="main">
	<div class="ui-form bd-b">
	<form method="post" id="comment-post">
	<input type="hidden" name="mid" value="{$mid}"/>
	<input type="hidden" name="itemid" value="{$itemid}"/>
	<input type="hidden" name="items" value="{$items}"/>
	<input type="hidden" name="page" value="{$page}"/>
	<input type="hidden" name="qid" value="0" id="qid"/>
	<input type="hidden" name="submit" value="1"/>
	<input type="hidden" name="star" value="3" id="star"/>
	<div><textarea name="content" id="content" placeholder="我来说两句" onblur="window.scrollTo(0,0);" style="margin:6px 0;height:48px;border:none;" onfocus="$('#box-btn').slideDown(300);$('#c0').show();$('#c1').hide();"></textarea></div>
	<section id="box-btn" style="display:none;">
	<div class="bd-t" id="box-star">
	<span class="star_e" onclick="$('#emoji').slideToggle('fast');"></span>
	<span id="star_3" class="star_a" onclick="Dstar(3);">好评</span>
	<span id="star_2" class="star_b" onclick="Dstar(2);">中评</span>
	<span id="star_1" class="star_b" onclick="Dstar(1);">差评</span>
	</div>
	{if $need_captcha}
	<div class="bd-t">{template 'captcha', 'chip'}</div>
	{/if}
	<div class="blank-16 bd-t"></div>
	<input type="button" class="btn-blue" value="发表评论" onclick="Dcomment();"/>
	<div class="blank-16"></div>
	</section>
	</form>	
	</div>
	{if $lists}
	{loop $lists $k $v}
	<div class="list-user">
	<img src="{useravatar($v[uname])}" width="32" height="32"/>
	<ul>
	<li><span>{$v[floor]}楼</span><a href="{userurl($v[uname])}" class="b" rel="external">{$v[name]}</a></li>
	<li><em>{if $v[star]==1}差评{elseif $v[star]==2}中评{else}好评{/if} {$v[addtime]}</em></li>
	</ul>
	</div>
	<div class="content">
	{if $v[quotation]}{$v[quotation]}{else}{$v[content]}{/if}
	{if $v[reply]}
	<br/><span class="px12 f_gray">{if $v[editor]}<span style="color:red;">管理员</span>{else}<span style="color:blue;">{$v[replyer]}</span>{/if} {timetodate($v[replytime], 5)} 回复： </span>
	<br/>{nl2br($v[reply])}
	{/if}
	</div>
	{/loop}
	{else}
	<div class="list-empty">暂无评论</div>
	{/if}
</div>
{if $pages}<div class="pages">{$pages}</div>{/if}
<script type="text/javascript">
function Dstar(v) {
	for(var i = 1; i < 4; i++) {
		if(v == i) {
			$('#star').val(i);
			$('#star_'+i).attr('class', 'star_a');
		} else {
			$('#star_'+i).attr('class', 'star_b');
		}
	}
}
function Dcomment() {
	var len;
	len = $('#content').val().length;
	if(len < {$MOD[comment_min]}) {
		Dtoast('正文最少个{$MOD[comment_min]}字，已填写'+len+'个字');
		return false;
	}
	if(len > {$MOD[comment_max]}) {
		Dtoast('正文最多个{$MOD[comment_max]}字，已填写'+len+'个字');
		return false;
	}
	{if $need_captcha}
	if($('#ccaptcha').html().indexOf('ok.png') == -1) {
		Dtoast('请填写验证码');
		return false;
	}
	{/if}
	$.post('index.php', $('#comment-post').serialize(), function(data) {
		if(data.indexOf('alert(') == -1) {
			Dtoast('评论发表成功');
			setTimeout(function() {
				if($('#page-last').length > 0) {
					Go($('#page-last').attr('href'));
				} else {
					window.location.reload();
				}
			}, 1000);
		} else {
			var t0 = data.split("alert('");
			var t1 = t0[1].split("')");
			var msg = t1[0];
			Dtoast(msg);
			if(msg.indexOf('审核') != -1) {
				setTimeout(function() {
					window.location.reload();
				}, 1000);
			} else {
				reloadcaptcha();
			}
		}
	});
}
{if $need_captcha}
$(function(){
	$('#captcha').on('blur', function(){window.scrollTo(0,0);});
	$('#captcha').css({'width':'100px','border':'none','padding':'0','font-size':'16px'});
});
{/if}
</script>
{/if}
{template 'footer'}